package top.yueyazhui.vhr.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.yueyazhui.vhr.mapper.MenuRoleMapper;

import java.util.List;

@Service
public class MenuRoleService {

    @Autowired
    MenuRoleMapper menuRoleMapper;

    public List<Integer> getMIdsByRId(Integer rid) {
        return menuRoleMapper.getMIdsByRId(rid);
    }

    public boolean update(Integer rid, Integer[] mids) {
        menuRoleMapper.deleteByRId(rid);
        if(mids != null) {
            Integer result = menuRoleMapper.insertRecord(rid, mids);
            return result == mids.length;
        } else {
            return true;
        }
    }
}
